Skip to content

feat(hyva): make the Banner Slider work on Hyvä (JS + CSS)#1

Open
ayeshanisar786 wants to merge 2 commits into
mainfrom
feat/hyva-slider-support
Open

feat(hyva): make the Banner Slider work on Hyvä (JS + CSS)#1
ayeshanisar786 wants to merge 2 commits into
mainfrom
feat/hyva-slider-support

Conversation

@ayeshanisar786

Copy link
Copy Markdown
Contributor

The slider only worked on Luma — on Hyvä it never animated (only the first, unstyled slide showed). Two Hyvä gaps, both fixed in slider.phtml (no new files):

Root cause

  1. No JS on Hyvä — the slider inits via text/x-magento-init → requireJS (ETechFlow_BannerSlider/js/slider). Hyvä strips requireJS + x-magento-init, so it never initialised (no rotation, no arrows/bullets).
  2. No CSS on Hyvä — the storefront styles ship as _module.less, compiled only by Magentoʼs (Luma) LESS pipeline. Hyvä doesnʼt compile Magento LESS, so the slider had zero CSS — slides rendered position:static; opacity:1, stacked and unstyled.

Fix

  • Inline <style id="ef-bs-hyva-css"> with the compiled-equivalent slider CSS (viewport aspect-ratio, absolute stacked slides, .is-active crossfade, effect-slide, arrows, bullets, mobile). Identical rules → harmless duplicate on Luma.
  • A guarded vanilla controller that runs only when window.require is absent (i.e. Hyvä); Luma still uses the existing x-magento-init/requireJS path. It reuses the same markup + .is-active crossfade and honours the admin settings: autoplay, speed, loop, arrows, bullets, pause-on-hover.

Verified

Tested live on the demo store on both themes via browser automation — 3 banners crossfade-rotate 1→2→0→1, arrows/bullets work, autoplay + pause-on-hover correct.

Notes / follow-ups

  • This is the minimal, self-contained fix. A fuller Hyvä port could also mirror the targeting (targeting.js, customer-data section) and click tracking (tracker.js) which are likewise requireJS-only today — out of scope here (basic slider parity first).
  • The inline <style> is emitted per rendered slider; if multiple sliders appear on one page it could be guarded to emit once. Minor.

🤖 Generated with Claude Code

ranawaqas45 and others added 2 commits July 6, 2026 23:11
The slider only worked on Luma. Two Hyvä gaps:

- JS: the slider inits via text/x-magento-init -> requireJS (slider.js).
  Hyvä strips requireJS + x-magento-init, so it never initialised.
- CSS: styles ship as _module.less (Luma pipeline only). Hyvä does not
  compile Magento LESS, so the slider had NO CSS (slides rendered
  position:static, opacity:1 — stacked and unstyled).

Fix (in slider.phtml, no new files, works on both themes):
- Inline <style id=ef-bs-hyva-css> with the compiled-equivalent slider CSS.
- A guarded vanilla controller that runs ONLY when window.require is absent
  (Hyvä); Luma still uses the existing x-magento-init/requireJS path. It
  reuses the same markup + .is-active crossfade and honours the admin
  settings (autoplay, speed, loop, arrows, bullets, pause-on-hover).

Verified live on both themes (Hyvä + Luma): 3 banners crossfade-rotate,
arrows/bullets work, autoplay + pause-on-hover correct.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The requireJS slider.js normally un-lazies each slide image (lazyLoad).
On Hyvä that never runs, so slides 2..n kept their loading=lazy /
data-src placeholder inside a visibility:hidden slide and rendered blank.

Add loadSlide(): swap data-src->src, data-srcset->srcset, and force
loading=eager (re-assigning src) for the shown slide + preload the next.
Verified on the demo: all 3 banner images load and rotate on Hyvä.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants